﻿package net.wangit.jdbc.sqltype;

import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;

public class BigDecimalSqlType extends NullableSqlType {

	private static final long serialVersionUID = 1L;

	public BigDecimalSqlType() {
	}

	public String get(ResultSet rs, String name) throws SQLException {
		BigDecimal value = rs.getBigDecimal(name);
		if (rs.wasNull())
			return null;
		else
			return value.toString();
	}

	public void setNotNull(PreparedStatement st, String value, int index)
			throws SQLException {
		st.setBigDecimal(index, new BigDecimal(value));
	}

	public int sqlType() {
		return Types.NUMERIC;
	}
}
